package com.hisan.freeride.home;

import android.content.Context;
import android.os.SystemClock;

import com.alibaba.sdk.android.push.MessageReceiver;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import com.blankj.utilcode.util.LogUtils;

import java.util.Map;

/**
 * Created by admin on 2017/5/20.
 */

public class MyMessageReceiver extends MessageReceiver {
    // 消息接收部分的LOG_TAG
    public static final String REC_TAG = "receiver";
   // private NotifyUtil currentNotify;
    private int requestCode = (int) SystemClock.uptimeMillis();
    @Override
    public void onNotification(Context context, String title1, String summary, Map<String, String> extraMap) {
        // TODO 处理推送通知
        LogUtils.v("xxx", "1Receive notification, title: " + title1 + ", summary: " + summary + ", extraMap: " + extraMap);
    }
    @Override
    public void onMessage(Context context, CPushMessage cPushMessage) {
        LogUtils.v("xxx", "1Receive notification, title: " + cPushMessage.getTitle() + ", summary: " + cPushMessage.getMessageId() );
//        Intent intent = new Intent(context, MainActivity.class);
//        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//        PendingIntent pIntent = PendingIntent.getActivity(context,
//                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
//        int smallIcon = R.mipmap.sfcar;
//        String ticker = "您有一条新通知";
//        String title = cPushMessage.getTitle();
//        String content =cPushMessage.getTitle();
//        //实例化工具类，并且调用接口
//        NotifyUtil notify1 = new NotifyUtil(context, 1);
//        notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
    }

    @Override
    public void onNotificationOpened(Context context, String title, String summary, String extraMap) {
        LogUtils.v("xxx", "3onNotificationOpened, title: " + title + ", summary: " + summary + ", extraMap:" + extraMap);
    }
    @Override
    protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
        LogUtils.v("xxx", "4onNotificationClickedWithNoAction, title: " + title + ", summary: " + summary + ", extraMap:" + extraMap);
    }
    @Override
    protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {

    }


    @Override
    protected void onNotificationRemoved(Context context, String messageId) {
        LogUtils.v("xxx", "6onNotificationRemoved");
    }
}
